﻿@model DTcms.Model.users
@{
    ViewBag.Title = "编辑会员";
    DTcms.Model.user_login_log logModel = ViewBag.logModel;
}
<form id="form1" class="layui-form" url="UserSave?action=@ViewBag.action&id=@ViewBag.id">
    @Html.AntiForgeryToken()
    <!--导航栏-->
    <div class="pageheader">
        <div class="page-bar">
            <ul class="page-breadcrumb">
                <li><a href="../users/user_list" class="back"><i class="fa fa-mail-reply-all"></i> 返回列表页</a></li>
                <li><a href="javascript:;"><i class="iconfont icon-home1"></i> 首页</a> </li>
                <li><a href="../users/user_list">会员管理</a> </li>
                <li><a href="javascript:;">编辑会员</a> </li>
            </ul>
        </div>
    </div>
    <!--/导航栏-->
    <!--内容-->
    <div class="layui-fluid">
        <div class="layui-tab layui-tab-card">
            <ul class="layui-tab-title" id="floatHead">
                <li class="layui-this">基本资料</li>
                <li>账户信息</li>
            </ul>
            <div class="layui-tab-content">
                <div class="layui-tab-item layui-show">
                    <div class="layui-form-item">
                        <label class="layui-form-label">所属组别</label>
                        <div class="layui-input-block">
                            <select class="select" name="group_id" url="/webapi/groupJson" selectValue="@Model.group_id" promtion="请选择组别" datatype="*" errormsg="请选择组别" sucmsg=" "><option value="">请选择组别...</option></select>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">用户状态</label>
                        <div class="layui-input-block">
                            @Html.RadioButton("status", 0, Model.status == 0, new { id= "status_0",title = "正常" })
                            @Html.RadioButton("status", 1, Model.status == 1, new { id= "status_1",title = "待验证" })
                            @Html.RadioButton("status", 2, Model.status == 2, new { id= "status_2",title = "待审核" })
                            @Html.RadioButton("status", 3, Model.status == 3, new { id= "status_3",title = "禁用" })
                            <span class="Validform_checktip">*禁用账户无法登录</span>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">用户名</label>
                        <div class="layui-input-block">
                            @Html.TextBox("user_name", Model.user_name, new { @class = "input normal", datatype = "*2-100", sucmsg = " ", ajaxurl = "/admin_ajax/username_validate" })
                            <span class="Validform_checktip">*登录的用户名，支持中文</span>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">登录密码</label>
                        <div class="layui-input-block">@Html.Password("txtPassword", Model.password, new { @class = "input normal", datatype = "*6-20", nullmsg = "密码范围在6-20位之间", sucmsg = " " }) <span class="Validform_checktip">*登录的密码，至少6位</span></div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">确认密码</label>
                        <div class="layui-input-block">@Html.Password("password", Model.password, new { @class = "input normal", datatype = "*", recheck = "txtPassword", nullmsg = "请再输入一次密码", errormsg = "两次输入的密码不一致", sucmsg = " " }) <span class="Validform_checktip">*再次输入密码</span></div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">邮箱账号</label>
                        <div class="layui-input-block">@Html.TextBox("email", Model.email, new { @class = "input normal", datatype = "*0-50", sucmsg = " " }) <span class="Validform_checktip">*取回密码时用到</span></div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">用户昵称</label>
                        <div class="layui-input-block">@Html.TextBox("nick_name", Model.nick_name, new { @class = "input normal" })</div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">上传头像</label>
                        <div class="layui-input-block">
                            @Html.TextBox("avatar", Model.avatar, new { @class = "input normal upload-path" })
                            <div class="upload-box choose-pick"><a href="javascript:;" class="webuploader-pick" title="图片空间">选择图片</a></div>
                            <div class="upload-box upload-img"></div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">用户性别</label>
                        <div class="layui-input-block">
                            @Html.RadioButton("sex", "保密", Model.sex == "保密", new { id= "sex_0",title = "保密" })
                            @Html.RadioButton("sex", "男", Model.sex == "男", new { id= "sex_1",title = "男" })
                            @Html.RadioButton("sex", "女", Model.sex == "女", new { id= "sex_2",title = "女" })
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">生日日期</label>
                        <div class="layui-input-block">
                            @Html.TextBox("birthday", Model.birthday != null ? Model.birthday.GetValueOrDefault().ToString("yyyy-M-d") : "", new { @class = "input rule-date-input", datatype = @"/^\s*$|^\d{4}\-\d{1,2}\-\d{1,2}$/", errormsg = "请选择正确的日期", sucmsg = " " })
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">手机号码</label>
                        <div class="layui-input-block">@Html.TextBox("mobile", Model.mobile, new { @class = "input normal" })</div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">电话号码</label>
                        <div class="layui-input-block">@Html.TextBox("telphone", Model.telphone, new { @class = "input normal" })</div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">QQ号码</label>
                        <div class="layui-input-block">@Html.TextBox("qq", Model.qq, new { @class = "input normal" })</div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">MSN</label>
                        <div class="layui-input-block">@Html.TextBox("msn", Model.msn, new { @class = "input normal" })</div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">通讯地址</label>
                        <div class="layui-input-block">@Html.TextBox("address", Model.address, new { @class = "input normal" })</div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">个性签名</label>
                        <div class="layui-input-block">
                            @Html.TextArea("signature", Model.signature, new { @class = "input" })
                        </div>
                    </div>
                </div>
                <div class="layui-tab-item">
                    <div class="layui-form-item">
                        <label class="layui-form-label">账户金额</label>
                        <div class="layui-input-block">
                            @Html.TextBox("amount", Model.amount, new { @class = "input small", datatype = @"/^(([1-9]{1}\d*)|([0]{1}))(\.(\d){1,2})?$/", sucmsg = " " }) 元
                            <span class="Validform_checktip">*账户上的余额</span>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">账户积分</label>
                        <div class="layui-input-block">
                            @Html.TextBox("point", Model.point, new { @class = "input small", datatype = "n", sucmsg = " " }) 分
                            <span class="Validform_checktip">*积分也可做为交易</span>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">升级经验值</label>
                        <div class="layui-input-block">
                            @Html.TextBox("exp", Model.exp, new { @class = "input small", datatype = "n", sucmsg = " " })
                            <span class="Validform_checktip">*根据积分计算得来，与积分不同的是只增不减</span>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">注册时间</label>
                        <div class="layui-input-block">@(Model.reg_time.ToString() != "" ? Model.reg_time.ToString() : "-")</div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">注册IP</label>
                        <div class="layui-input-block">@(Model.reg_ip != "" ? Model.reg_ip : "-")</div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">最近登录时间</label>
                        <div class="layui-input-block">@(logModel == null ? "-" : logModel.login_time.ToString("yyyy-MM-dd"))</div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">最近登录IP</label>
                        <div class="layui-input-block">@(logModel == null ? "-" : logModel.login_ip)</div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!--/内容-->
    <!--工具栏-->
    <div class="page-footer">
        <div class="btn-wrap">
            <button class="layui-btn icon-btn" id="btnSubmit"><i class="layui-icon layui-icon-ok"></i>提交保存</button>
            <button class="layui-btn layui-btn-warm icon-btn" name="btnReturn" onclick="javascript:history.back(-1);"><i class="layui-icon layui-icon-return"></i>返回上一页</button>
        </div>
    </div>
    <!--/工具栏-->
</form>
@section Scripts{
    <script type="text/javascript" src="/scripts/libs/js/uploader.js"></script>
    <script type="text/javascript">
        layui.use(['cascadeSelect', 'validform', 'jqueryform', 'laydate', 'fileChoose'], function () {
            var cascadeSelect = layui.cascadeSelect, laydate = layui.laydate, fileChoose = layui.fileChoose;
            cascadeSelect.init('group_id', false);
            laydate.render({
                elem: '#birthday'
            });
            $('.choose-pick').click(function () {
                var obj = $(this);
                fileChoose.open({
                    fileUrl: '',
                    listUrl: '/admin_ajax/files',
                    num: 1,
                    dialog: {
                        offset: '60px'
                    },
                    onChoose: function (res) {
                        if (res[0].type != "file") {
                            layer.msg('我只让你选择图片格式的文件', { icon: 2, time: 2000 }, function () { });
                            return;
                        }
                        obj.siblings(".upload-path").val(res[0].url);
                        obj.siblings(".layer-photos").show().find("img").attr("src", res[0].url);
                    }
                });
            });
            //初始化表单验证
            $("#form1").initValidform('#btnSubmit', 1);
            //初始化上传控件
            $(".upload-img").InitUploader({ sendurl: "/upload_ajax/action", swf: "/scripts/libs/module/uploader/uploader.swf" });
        });
    </script>
}